home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / common / headers.h / piformat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-14  |  10.0 KB  |  272 lines

  1. /*
  2.     File: PIFormat.h
  3.  
  4.     Copyright (c) 1992-6, Adobe Systems Incorporated.
  5.     All rights reserved.
  6.  
  7.     This file describes version 1 of Photoshop's plug-in image format interface.
  8. */
  9.  
  10. #ifndef __PIFormat__
  11. #define __PIFormat__
  12.  
  13. #include "PIActions.h"
  14. #include "PIGeneral.h"
  15.  
  16. /* Operation selectors */
  17.  
  18. #define formatSelectorAbout              0
  19.  
  20. #define formatSelectorReadPrepare         1
  21. #define formatSelectorReadStart          2
  22. #define formatSelectorReadContinue         3
  23. #define formatSelectorReadFinish         4
  24.  
  25. #define formatSelectorOptionsPrepare     5
  26. #define formatSelectorOptionsStart         6
  27. #define formatSelectorOptionsContinue     7
  28. #define formatSelectorOptionsFinish      8
  29.  
  30. #define formatSelectorEstimatePrepare     9
  31. #define formatSelectorEstimateStart     10
  32. #define formatSelectorEstimateContinue    11
  33. #define formatSelectorEstimateFinish    12
  34.  
  35. #define formatSelectorWritePrepare        13
  36. #define formatSelectorWriteStart        14
  37. #define formatSelectorWriteContinue     15
  38. #define formatSelectorWriteFinish        16
  39.  
  40. #define formatSelectorFilterFile        17
  41.  
  42. /*    We keep various pieces of information about the file format in the PiMI resource.
  43.     Here is the structure of that resource. */
  44.  
  45. /******************************************************************************/
  46.  
  47. #define PIFmtFileTypeProperty   0x666d5443 /* 'fmTC' <TypeCreatorPair> Default file type for file format. */
  48. #define PIReadTypesProperty        0x52645479 /* 'RdTy' <TypeCreatorPair []> File type info for file format plugins */
  49. #define PIFilteredTypesProperty    0x66667454 /* 'fftT' <TypeCreatorPair []> File types to filter for file format plugins */
  50. #define PIReadExtProperty        0x52644578 /* 'RdEx' <OSType []> File type info for file format plugins */
  51. #define PIFilteredExtProperty    0x66667445 /* 'fftE' <OSType []> File types to filter for file format plugins */
  52. #define PIFmtFlagsProperty        0x666d7466 /* 'fmtf' <Set> Format flags */
  53.  
  54. #define PIFmtMaxSizeProperty    0x6d78737a /* 'mxsz' <Point> Max rows and cols supported by this format. */
  55. #define PIFmtMaxChannelsProperty 0x6d786368 /* 'mxch' <int16 []> Max channels per mode for this format. */
  56.  
  57. /******************************************************************************/
  58.  
  59. /* Format flags indices. */
  60.  
  61. #define PIFmtReadsAllTypesFlag 0
  62. #define PIFmtSavesImageResourcesFlag 1
  63. #define PIFmtCanReadFlag 2
  64. #define PIFmtCanWriteFlag 3
  65. #define PIFmtCanWriteIfReadFlag 4
  66.  
  67. /******************************************************************************/
  68.  
  69. /* Pragma to byte align structures; for Borland C */
  70.  
  71. #if defined(__BORLANDC__)
  72. #pragma option -a-
  73. #endif
  74.  
  75. /* Pragma to byte align structures; for Microsoft C */
  76. #if WIN32
  77. #pragma pack(push,1)
  78. #endif
  79.  
  80. /******************************************************************************/
  81.  
  82. #if PRAGMA_ALIGN_SUPPORTED
  83. #pragma options align=mac68k
  84. #endif
  85.  
  86. typedef struct FormatInfo
  87.     {
  88.  
  89.     PlugInInfo    plugInInfo;             /* The information common to all plug-ins.            */
  90.     int16        typeCount;                /* The number of types in the type list.            */
  91.     int16        extensionCount;         /* The number of extensions in the type list.        */
  92.     Boolean     canRead;                /* Can we read using this format?                    */
  93.     Boolean     readsAllTypes;            /* Can this plug-in read from all files?            */
  94.     Boolean     canWrite;                /* Can we write using this format?                    */
  95.     Boolean        canWriteIfRead;            /* Can we write if we read using this format?         */
  96.     Boolean     savesImageResources;    /* Does this file format save the resource data.    */
  97.     Boolean        padFlag;                /* Padding */
  98.     int16        maxChannels [16];        /* Maximum # of channels with each plug-in mode.    */
  99.     int16        maxRows;                /* Maximum rows allowed in document.                */
  100.     int16        maxCols;                /* Maximum columns allowed in document.             */
  101.     OSType        fileType;                /* The file type if we create a file.                */
  102.     OSType        creatorType;            /* The creator type if we create a file.            */
  103.     OSType        typeList [1];            /* The types and extensions supported.                */
  104.  
  105.     }
  106. FormatInfo;
  107.  
  108. /******************************************************************************/
  109. /* turn off the byte align pragma back to its original state; only for Borland C */
  110. #if defined(__BORLANDC__)
  111. #pragma option -a.
  112. #endif
  113.  
  114. /* Pragma to turn off align structures for Microsoft C */
  115. #if WIN32
  116. #pragma pack(pop)
  117. #endif
  118. /******************************************************************************/
  119.  
  120. /*    Error return values. The plug-in module may also return standard Macintosh
  121.     operating system error codes, or report its own errors, in which case it
  122.     can return any positive integer. */
  123.  
  124. #define formatBadParameters -30500
  125. #define formatCannotRead    -30501
  126.  
  127. #if WIN32
  128. #pragma pack(push,4)
  129. #endif
  130.  
  131. typedef struct FormatRecord
  132.     {
  133.  
  134.     int32                serialNumber;    /* Host's serial number, to allow
  135.                                            copy protected plug-in modules. */
  136.  
  137.     TestAbortProc        abortProc;        /* The plug-in module may call this no-argument
  138.                                            BOOLEAN function (using Pascal calling
  139.                                            conventions) several times a second during long
  140.                                            operations to allow the user to abort the operation.
  141.                                            If it returns TRUE, the operation should be aborted
  142.                                            (and a positive error code returned). */
  143.  
  144.     ProgressProc        progressProc;    /* The plug-in module may call this two-argument
  145.                                            procedure periodically to update a progress
  146.                                            indicator.  The first parameter is the number
  147.                                            of operations completed; the second is the total
  148.                                            number of operations. */
  149.  
  150.     int32                maxData;        /* Maximum number of bytes that should be
  151.                                            passed back at once, plus the size of any
  152.                                            interal buffers. The plug-in may reduce this
  153.                                            value in the formatSelectorPrepare routine. */
  154.  
  155.     int32                minDataBytes;    /* Disk space needed for the data fork. */
  156.     int32                maxDataBytes;    /* Disk space needed for the data fork. */
  157.  
  158.     int32                minRsrcBytes;    /* Disk space needed for the resource fork. */
  159.     int32                maxRsrcBytes;    /* Disk space needed for the resource fork. */
  160.  
  161.     int32                dataFork;        /* refnum for the data fork. */
  162.     int32                rsrcFork;        /* refnum for the resource fork. */
  163.     
  164.     FSSpec *            fileSpec;        /* Full file specification. */
  165.  
  166.     int16                imageMode;        /* Image mode */
  167.     Point                imageSize;        /* Size of image */
  168.     int16                depth;            /* Bits per sample, currently must be 1 or 8 */
  169.     int16                planes;         /* Samples per pixel */
  170.  
  171.     Fixed                imageHRes;        /* Pixels per inch */
  172.     Fixed                imageVRes;        /* Pixels per inch */
  173.  
  174.     LookUpTable            redLUT;         /* Red LUT, only used for Indexed Color images */
  175.     LookUpTable            greenLUT;        /* Green LUT, only used for Indexed Color images */
  176.     LookUpTable            blueLUT;        /* Blue LUT, only used for Indexed Color images */
  177.  
  178.     void *                data;            /* A pointer to the returned image data. The
  179.                                            plug-in module is responsible for freeing
  180.                                            this buffer. Should be set to NIL when
  181.                                            all the image data has been returned. */
  182.  
  183.     Rect                theRect;        /* Rectangle being returned */
  184.     int16                loPlane;        /* First plane being returned */
  185.     int16                hiPlane;        /* Last plane being returned */
  186.     int16                colBytes;        /* Spacing between columns */
  187.     int32                rowBytes;        /* Spacing between rows */
  188.     int32                planeBytes;     /* Spacing between planes (ignored if only one
  189.                                            plane is returned at a time) */
  190.     PlaneMap            planeMap;        /* Maps plug-in plane numbers to host plane
  191.                                            numbers.  The host initializes this is a linear
  192.                                            mapping.  The plug-in may change this mapping if
  193.                                            it sees the data in a different order. */
  194.  
  195.     Boolean             canTranspose;    /* Is the host able to transpose the image? */
  196.     Boolean             needTranspose;    /* Does the plug-in need the image transposed? */
  197.  
  198.     OSType                hostSig;        /* Creator code for host application */
  199.     HostProc            hostProc;        /* Host specific callback procedure */
  200.  
  201.     int16                hostModes;        /* Used by the host to inform the plug-in which
  202.                                            imageMode values it supports.  If the corresponding
  203.                                            bit (LSB = bit 0) is 1, the mode is supported. */
  204.  
  205.     Handle                revertInfo;     /* Information to be kept with the document for reverting or
  206.                                            saving.    Where possible this handle should be used to
  207.                                            avoid bringing up an options dialog. */
  208.  
  209.     NewPIHandleProc        hostNewHdl;     /* Handle allocation and disposal for revert info. */
  210.     DisposePIHandleProc    hostDisposeHdl;
  211.     
  212.     Handle                imageRsrcData;    /* Handle containing the block of resource data. */
  213.     int32                imageRsrcSize;    /* size of image resources. */
  214.  
  215.     PlugInMonitor        monitor;        /* The host's monitor. */
  216.  
  217.     void *                platformData;    /* Platform specific information. */
  218.  
  219.     BufferProcs *        bufferProcs;    /* The procedures for allocating and */
  220.                                         /* releasing buffers. */
  221.                                         
  222.     ResourceProcs *        resourceProcs;    /* Plug-in resource procedures. */
  223.  
  224.     ProcessEventProc    processEvent;    /* Pass event to the application. */
  225.     
  226.     DisplayPixelsProc    displayPixels;    /* Display dithered pixels. */
  227.  
  228.     HandleProcs            *handleProcs;    /* Platform independent handle manipulation. */
  229.     
  230.     /* New in 3.0. */
  231.     
  232.     OSType                fileType;        /* File-type for filtering */
  233.  
  234.     ColorServicesProc    colorServices; /* Routine to access color services. */
  235.     
  236.     AdvanceStateProc    advanceState;    /* Valid from continue selectors. */
  237.  
  238.     /* New in 3.0.4. */
  239.     
  240.     PropertyProcs        *propertyProcs; /* A suite to allow getting and setting image
  241.                                            document properties. */
  242.  
  243.     ImageServicesProcs    *imageServicesProcs;
  244.                                         /* The suite of image processing services
  245.                                            callbacks. */
  246.     
  247.     int16                tileWidth;        /* The width of the tiles. Zero if not set. */
  248.     int16                tileHeight;        /* The height of the tiles. Zero if not set. */
  249.     
  250.     Point                tileOrigin;        /* The origin point for the tiles. */
  251.     
  252.     /* New in 4.0 */
  253.     
  254.     PIDescriptorParameters    *descriptorParameters;    /* For recording and playback */
  255.     Str255                    *errorString;            /* For silent and errReportString */
  256.  
  257.     char                reserved [212]; /* Set to zero */
  258.  
  259.     }
  260. FormatRecord, *FormatRecordPtr;
  261.  
  262. #if WIN32
  263. #pragma pack(pop)
  264. #endif
  265.  
  266. #if PRAGMA_ALIGN_SUPPORTED
  267. #pragma options align=reset
  268. #endif
  269.  
  270. /******************************************************************************/
  271. #endif
  272.